<?php
require_once '../setting.php';
require_once ROOTPATH . 'functions.php';
require_once INCLUDESPATH . 'db/Word.php';
require_once INCLUDESPATH . 'db/WordDAO.php';

class WordDAOTest {

	var $wd = null;
	function WordDAOTest() {
		$this->wd = new WordDAO();
	}

	function testInsert() {
		$word = new Word();
		$word->setUserid(1);
		$word->setKey("gigi");
		$word->setPS("jiji");
		$word->setPron("http:///....");
		$word->setAcceptation("n. jiji");
		$word->setStatus('inbox');
		$this->wd->insert($word);
	}

	function testUpdate() {
		$word = $this->wd;
	}

	function testDelete() {
		$this->wd->delete(2);
	}

	function testRetrieve() {
		return $this->wd->retrieveById(2);
	}

	function testRetrieveByProperty() {
		return $this->wd->retrieveByProperty('userid', 1);
	}

	function testRetrieveByProperty2() {
		return $this->wd->retrieveByProperty('userid', 1, 'id', 1, 2);
	}

	function testRetrieveByProperties() {
		$properties = array('userid' => 1, 'key' => 'do');
		return $this->wd->retrieveByProperties($properties, 'id', 1);
	}

	function testRetrieveByPropertiesWithPage() {
		$properties = array('userid' => 1);
		return $this->wd->retrieveByProperties($properties, 'id', 1, 2, 2);
	}

	function testStatistic() {
		return $this->wd->statistic();
	}

	function testStatistic2() {
		$params = array ('userid' => 3, 'status' => 'inbox');
		return $this->wd->statistic($params);
	}
}
echo '<pre>';
$wdt = new WordDAOTest();
//$wdt->testInsert();
//print_r($wdt->testRetrieveByProperty());
print_r($wdt->testRetrieveByProperties());
//$wdt->testDelete();
//echo $wdt->testStatistic2();
echo '</pre>';
?>